package com.rick.minio.controller;


import com.alibaba.fastjson.JSONObject;
import com.rick.minio.service.UploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Auther:wangyaozu
 * @Date: 2024/4/27 - 04 - 27 - 10:43
 * @Description: com.rick.minio.controller
 * @version:1.0
 */
@RestController
public class UploadFileController {

    @Autowired
    private UploadService uploadService;

    @PostMapping("/createBucket")
    public JSONObject makeBucket(@RequestBody  String bucketName){
        uploadService.makeBucket(bucketName);

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("flag","success");
        return jsonObject;

    }


    @PostMapping("/uploadFile")
    public JSONObject uploadFile(@RequestBody MultipartFile file){
        uploadService.upload(file);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("flag","success");
        return jsonObject;

    }




}
